const Router = require('koa-router');
const tool = require("../../tools/tool");
const router = new Router();
const {db, Op, QueryTypes} = require("../../models/db");
const tools = require("../../tools/tool");
// 今日已收款  手机
router.post('/ldsk/sklistDone', async ctx => {
    let uid = ctx.user.id
    // 今日已收款 表示收款时间在今天的已收款票据
    let sql = `
        SELECT a.*,b.name buName from
            (
                SELECT b.buId,sum(a.leftAmount) leftAmount,count(*) bills 
                from app_sk a inner join invoice b on a.billId=b.id WHERE a.doId=${uid} and a.billState=N'已收款' 
                and convert(varchar(10),a.accountedAt,120)='${tool.getDay()}' GROUP BY b.buId
            ) a inner join contact b on a.buId=b.id
    `
    let list = await db.query(sql, {type: QueryTypes.SELECT})
    return ctx.suc('', list)
})




module.exports = router;